﻿@using System.Data;
@using System.Web;
@using DTcms.Web.MVC.Areas.Web.Controllers;
@using DTcms.Web.MVC.UI.Controllers;
@using DTcms.Model;
@{
   DTcms.Model.sites site = ViewData["site"] as DTcms.Model.sites;
   DTcms.Model.sysconfig config = ViewData["sysConfig"] as DTcms.Model.sysconfig;
   Layout = "~/Areas/Web/Views/" + site.build_path + "/Shared/_LayoutShow.cshtml";
   DTcms.Model.article m = ViewData["model"] as DTcms.Model.article;
   Article_ShowController bc = ViewBag.This as Article_ShowController;
   string category_title = bc.get_category_title(m.category_id, "购物商城");
   ViewBag.Title = m.title + " - " + category_title +" - " + site.name;
   string channel = "goods";
}
@section HeaderContent{
@if(m.is_msg == 1){
<script src="~/Scripts/jquery/jquery.form.min.js"></script>
}
<script src="~/Scripts/jquery/jquery.jqzoom.js"></script>
<script src="~/Areas/Web/Scripts/picture.js"></script>
<script src="~/Areas/Web/Scripts/cart.js"></script>

<script>
$(function(){
	//TAB切换
	tabs('#goodsTabs','click');
	//智能浮动层
	$("#tabHead").smartFloat();
   //初始化规格事件
	initGoodsSpec('@(config.webpath)tools/submit_ajax.ashx?action=bc.get_article_goods_info&channel_id=@m.channel_id');
});
</script>
}

<!--当前位置-->
@{string category_nav = bc.get_category_menu("goods_list", m.category_id);}
<div class="section">
  <div class="location">
    <span>当前位置：</span>
    <a href="@bc.linkurl("index")">首页</a> &gt;
        <a href="@bc.linkurl("goods")">购物商城</a>
    @Html.Raw(category_nav)
  </div>
</div>
<!--/当前位置-->

<div class="section">
  <div class="wrapper clearfix">
    <div class="wrap-box">
      <!--页面左边-->
      <div class="left-925">
        <div class="goods-box clearfix">
          <!--商品图片-->
          <div class="goods-pic">
            <!--幻灯片-->
            <div class="pic-box">
              <div class="pic-preview">
                <span class="jqzoom">
                  <img />
                </span>
              </div>
              <!--缩略图-->
              <div class="pic-scroll">
                <a class="prev">&lt;</a>
                <a class="next">&gt;</a>
                <div class="items">
                  <ul>
                    @if (m.albums != null) {
                      foreach (DTcms.Model.article_albums modelt in m.albums) {
                      <li>
                        <img bimg="@modelt.original_path" src="@modelt.thumb_path" onmousemove="preview(this);" /></li>
                      }
                    }
                  </ul>
                </div>
              </div>
              <!--缩略图-->
            </div>
            <!--/幻灯片-->
          </div>
          <!--/商品图片-->

          <!--商品信息-->
          <div class="goods-spec">
            <script type="text/javascript" src="@(config.webpath)tools/submit_ajax.ashx?action=view_article_click&channel_id=@m.channel_id&id=@m.id&click=1&hide=1"></script>
            <h1>@m.title</h1>
            <p class="subtitle">@m.fields["sub_title"]</p>
            <div class="spec-box">
              <dl>
                <dt>货号</dt>
                <dd id="commodityGoodsNo">@m.fields["goods_no"]</dd>
              </dl>
              <dl>
                <dt>市场价</dt>
                <dd><s id="commodityMarketPrice">¥@m.fields["market_price"]</s></dd>
              </dl>
              <dl>
                <dt>销售价</dt>
                <dd><em id="commoditySellPrice" class="price">¥@m.fields["sell_price"]</em></dd>
              </dl>
            </div>

            <div id="goodsSpecBox" class="spec-box line">
              <!--商品规格-->
              @{ List<DTcms.Model.article_goods_spec> specList = bc.get_article_goods_spec(m.channel_id, m.id, "parent_id=0");}
              @if (specList != null) {
                foreach (DTcms.Model.article_goods_spec modelt1 in specList) {
                <dl>
                  <dt>@modelt1.title</dt>
                  <dd>
                    <ul class="items">
                      <!--规格选项-->
                      @{ List<DTcms.Model.article_goods_spec> itemList = bc.get_article_goods_spec(m.channel_id, m.id, "parent_id=" + modelt1.spec_id);}
                      @if (itemList != null) {
                        foreach (DTcms.Model.article_goods_spec modelt2 in itemList) {
                        <li>
                          <a specid="@modelt2.spec_id" title="@modelt2.title" href="javascript:;">
                            @if (modelt2.img_url != null && modelt2.img_url != "") {
                              <img src="@modelt2.img_url" />
                            }
                            else {
                              <span>@modelt2.title</span>
                            }
                          </a>
                        </li>
                        }
                      }
                      <!--/规格选项-->
                    </ul>
                  </dd>
                </dl>
                }
              }
              <!--/商品规格-->
            </div>

            <div class="spec-box">
              <dl>
                <dt>购买数量</dt>
                <dd>
                  <div class="stock-box">
                    <input id="commodityChannelId" type="hidden" value="@m.channel_id" />
                    <input id="commodityArticleId" type="hidden" value="@m.id" />
                    <input id="commodityGoodsId" type="hidden" value="0" />
                    <input id="commoditySelectNum" type="text" maxlength="9" value="1" maxValue="@m.fields["stock_quantity"]" onkeydown="return checkNumber(event);">
                    <a class="add" onclick="addCartNum(1);">+</a>
                    <a class="remove" onclick="addCartNum(-1);">-</a>
                  </div>
                  <span class="stock-txt">库存<em id="commodityStockNum">@m.fields["stock_quantity"]</em>件
                  </span>
                </dd>
              </dl>
              <dl>
                <dd>
                  <div id="buyButton" class="btn-buy">
                    <button class="buy" onclick="cartAdd(this,'@(config.webpath)',1,'@bc.linkurl("shopping")');">立即购买</button>
                    <button class="add" onclick="cartAdd(this,'@(config.webpath)',0,'@bc.linkurl("cart")');">加入购物车</button>
                  </div>
                </dd>
              </dl>
            </div>

            <div class="spec-box line">
              <dl>
                <dd>
                  <!--分享-->
                  @RenderPage("~/Areas/Web/Views/" + site.build_path + "/Shared/partial_share_js.cshtml")
                  <!--/分享-->
                </dd>
              </dl>
            </div>
          </div>
          <!--商品信息-->
          <div class="line20"></div>

          <!--商品介绍-->
          <div id="goodsTabs" class="goods-tab">
            <!--选项卡-->
            <div id="tabHead" class="tab-head">
              <ul>
                <li>
                  <a class="selected" href="javascript:;">商品介绍</a>
                </li>
                <li>
                  <a href="javascript:;">商品评论</a>
                </li>
              </ul>
            </div>
            <!--/选项卡-->

            <!--选项内容-->
            <div class="tab-content entry" style="display: block">
              @Html.Raw(m.content)
            </div>
            <div class="tab-content">
              <!--用户评论-->
              @if (m.is_msg == 1) {
                <div class="comment-box">
                  @RenderPage("~/Areas/Web/Views/" + site.build_path + "/Shared/partial_comment_box.cshtml")
                </div>
              }
              <!--用户评论-->
            </div>
            <!--选项内容-->
          </div>
          <!--/商品介绍-->
        </div>
      </div>
      <!--页面左边-->

      <!--页面右边-->
      <div class="left-220">
        <div class="bg-wrap nobg">
          <div class="sidebar-box">
            <h4>销售排行</h4>
            <ul class="rank-list">
              @{ DataTable hotGoods = bc.get_article_list(channel, 0, 10, "status=0", "click desc,id desc");}
              @for (int i = 0; i < hotGoods.Rows.Count; i++) {
                DataRow hotdr = hotGoods.Rows[i];
                <li>
                  <label class="@(i == 0 ? "hot" : "")"></label>

                  <a href="@bc.linkurl("goods_show", hotdr["id"])">@hotdr["title"]</a>
                </li>
              }
            </ul>
          </div>

          <div class="sidebar-box">
            <h4>推荐商品</h4>
            <div class="red-list">
              <ul>
                @{ DataTable redGoods = bc.get_article_list(channel, 0, 4, "status=0 and is_red=1");}
                @foreach (DataRow reddr in redGoods.Rows) {
                  <li>

                    <div class="img-box">
                      <a title="@reddr["title"]" href="@bc.linkurl("goods_show", reddr["id"])">
                        <img src="@reddr["img_url"]" />
                      </a>
                    </div>
                    <div class="txt-box">
                      <a title="@reddr["title"]" href="@bc.linkurl("goods_show", reddr["id"])">@reddr["title"]</a>
                      <span>@DateTime.Parse(reddr["add_time"].ToString()).ToString("yyyy-MM-dd")</span>
                    </div>
                  </li>
                }
              </ul>
            </div>
          </div>
        </div>
      </div>
      <!--/页面右边-->
    </div>
  </div>
</div>
